package com.code.pattern.factory.simplefactory;

import com.code.pattern.factory.ICourse;
import com.code.pattern.factory.PythonCourse;

/**
 * @author: liyufei
 * @date: 2021-03-13 13:27
 */
public class CourseFactoryTest {

    public static void main(String[] args) {

        // 创建简单工厂类
        CourseFactory factory = new CourseFactory();

        // 通过工厂类获取 Java课程对象
        ICourse java = factory.create("java");
        java.record();

        // 通过工厂类获取 Python课程对象
        // ICourse python = factory.create("python");
        ICourse python = factory.createByClassName("com.code.pattern.factory.PythonCourse");
        python.record();

        // 通过工厂类获取 Python课程对象
        ICourse python2 = factory.createByClass(PythonCourse.class);
        python2.record();
    }
}
